package example.Proxy;

import org.apache.commons.logging.Log;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import static java.rmi.server.LogStream.log;

public class UserServiceProxy implements UserService{
    private UserService userService;

    public UserServiceProxy() {
    }

    public UserServiceProxy(UserService userService) {
        this.userService = userService;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public void add() {
        log("add()");
        userService.add();

    }

    @Override
    public void delete() {
        log("delete()");
        userService.delete();

    }

    @Override
    public void update() {
        log("update()");
        userService.update();

    }

    @Override
    public void query() {

        log("query()");
        userService.query();
    }
    public void log(String methodName){
        Date currentDate=new Date();
        DateFormat dateFormat=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        System.out.println("["+dateFormat.format(currentDate)+"调用了核心业务逻辑方法"+methodName);

    }



}
